package cate.game.db.facade;

import cate.game.db.mongo.FriendBoxDao;
import cate.game.friend.po.FriendBox;

import java.util.Optional;

public class FriendBoxDaoFacade {
    public FriendBoxDao dao;

    public FriendBoxDaoFacade(FriendBoxDao dao){
        this.dao = dao;
    }

    public FriendBox find(String roleId){
        Optional<FriendBox> optional = dao.findById(roleId);
        return optional.orElse(null);
    }

    public void delete(String roleId){
        dao.deleteById(roleId);
    }

    public FriendBox upsert(FriendBox item){
        FriendBox box = null;
        try{
            box = dao.save(item);
        }catch (Exception e){
            e.printStackTrace();
        }
        return box;
    }
}
